< previous page page_577 next page >

Page 577
Now it's time to code the various methods you need to manage call tracing in Visual Basic 5. First, create the Public Sub methods Push and Pop. These two routines handle the details of keeping track of each function or sub as it is executed. Listing 14.33 shows the code for these two Public methods.
Type.gifListing 14.33. Coding the Push and Pop methods of the TraceObject.
Public Sub Push(ProcName As String)
    '
    ' push a proc onto the stack
    trcPointer = trcPointer + 1
    ReDim Preserve trcStack(trcPointer)
    trcStack(trcPointer) = ProcName
    '
End Sub

Public Sub Pop()
    '
    ' pop a proc off the stack
    If trcPointer <> 0 Then
        trcPointer = trcPointer - 1
        ReDim Preserve trcStack(trcPointer)
    End If
    '
End Sub
Now create another Public Sub method (Clear) and a Public Function method (List). Add the code from Listing 14.34 to the class.
Type.gifListing 14.34. Coding the List and Clear methods of the TraceObject.
Public Function List() As Variant
    '
    ' return an array of the trace log
    List = trcStack
    '
End Function

Public Sub Clear()
    '
    ' clear off the stack
    trcPointer = 0
    ReDim Preserve trcStack(0)
    '
End Sub

 
< previous page page_577 next page >

If you like this book, buy it!